<template>
  <div style="display: inline-block; margin-left: 20px; margin-right: 20px;">
    {{ title }}
    <div class="select-container cantSelect" 
    :class="{'active': isActive}"
    @click.self="isActive = !isActive"
    @blur="isActive = false"
    tabindex="0"
    >
      <span @click.self="isActive = true">{{ label }}</span> 

      <!-- 箭头 -->
      <div style="transition: all 0.2s; font-size: 10px;font-family:'iconfont'; width: 10px; position: absolute; top: 5px; transform: translate(150px,0);"
        :class="{'arrow-active': isActive}"
        @click.self="isActive = !isActive "
      >
        &#xe67d;
      </div>

      <!-- 下拉选框 -->
      <div class="selectList shadow">
        <slot></slot>
      </div>

    </div>
  </div>
</template>

<script>
export default {
  name: 'MySelect',
  props: ['user', 'title', 'modelValue'],
  data(){
    return{
      isActive: false,
      selectValue: 0,
      label: ''
    }
  },
  watch:{
    selectValue(){
      this.$emit('update:modelValue', this.selectValue)
    }
  }
}
</script>

<style scoped>
.select-container {
  transition: all 0.2s;
  width: 180px;
  height: 50px;
  display: inline-block;
  background-color: white;
  vertical-align: middle;
  border-radius: 15px;
  border: 1px solid rgb(206, 206, 206);
  padding: 5px;
  padding-left: 10px;
  line-height: 40px;
  box-sizing: border-box;
  position: relative;
}

.select-container.active {
  transition: all 0.2s;
  border: 1px solid rgb(83, 83, 238);
  box-shadow: 0 0 0 1px rgb(115, 115, 255);
}

.selectList {
  opacity: 0;
  transform: translate(0, 50px);
  max-height: 0;
  background-color: white;
  border-radius: 10px;
  border: 1px solid rgb(206, 206, 206);
  left: 0;
  top: 10px;
  overflow: hidden;
  overflow-y: auto;
  z-index: 1;
}

.select-container.active .selectList {
  transition: all 0.4s;
  opacity: 1;
  position: absolute;
  height: auto;
  max-height: 200px;
  width: 180px;
}

.selectList div {
  height: 40px;
}
.selectList div:hover {
  background-color: rgb(170, 170, 170);
}

.arrow-active {
  transition: all 0.2s;
  transform: translate(150px,0) rotate(180deg) !important;
}
</style>
